#usr/bin/bash

#随机密封数据

echo "等待lotus-storage-miner run中"
flag=true
while($flag)
	do
		flag=true
		if [ $(ps -ef | grep -c "lotus-storage-miner run") -gt 0 ] && [ $(ss -antlup | grep -c 2345) -gt 0 ]; 
			then flag=false; 
		fi
	done

echo "正在等待任务发送"
while(true)
	do
		if [ $(lotus-storage-miner info|grep Local|awk '{print $2}') -eq 0 ];
			then echo "发送 密封扇区 命令:lotus-storage-miner pledge-sector"
				lotus-storage-miner pledge-sector
				echo $(date +%Y-%m-%d" "%H:%M:%S)  "lotus-storage-miner pledge-sector" >> ~/lotusDir/history/lotus-storage-miner-send.history
				echo "发送完成";
		fi
		echo $(date +%Y-%m-%d" "%H:%M:%S)": 等待中..."
		sleep 300
	done